import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

export const useStore = defineStore('read', () => {
  const theme = ref('light') //默认主题为light

  const recentReadBookId = ref(0) //最近阅读的书籍id


  // 切换主题
  function toggleTheme () {
    if (theme.value === 'light') {
      theme.value = 'dark'
    } else {
      theme.value = 'light'
    }
  }


  // 设置最近阅读的书籍id
  function setRecentReadBookId (id) {
    recentReadBookId.value = id
  }



  return { theme, toggleTheme, recentReadBookId, setRecentReadBookId }
})
